<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    /**
     * 1、数字类型转换为字符串类型，值仍为
     * 数字类型时的值，但是类型变为字符串类型
     * 可以使用+""来进行隐式转换
     * 2、String()进行类型的强制转换
     */
    var num = 12345;
    var notNum = NaN;
    var str1 = num + "";
    var str2 = notNum +"";
    console.log(str1, str2);

    var b1 = true;
    var b2 = false;
    var str3 = b1 + "";
    var str4 = b2 + "";
    console.log(str3, str4);

    var u1 = undefined;
    var n1 = null;
    var str5 = String();

    //转换成Number类型
    var a = '123.456img';
    var a1 = parseInt(a);
    var a2 = parseFloat(a);
    document.write("a1=" + a1 +'<br/>'+ "a2=" + a2+'<br/>');
    document.write(typeof a2+'lbr/>');
    
    //转换成String类型
    var b = 3.1415926;
    var b1 = b + "";
    document.write(typeof(b1)+'<br/>');

    //转换成Boolean 类型
    var c='img'+3+'.jpg';
    var c1 = !!c;
    document.write('c1='+c1);
    alert(typeof c1);
</script>
</html>